//
//  TPArticleDetailCell.m
//  Yimei
//
//  Created by xiaowu xiaowu on 2017/10/30.
//  Copyright © 2017年 xiaowu xiaowu. All rights reserved.
//

#import "TPArticleDetailCell.h"
#import "TPArticleCommentModel.h"
#import "NSDate+Tripvi.h"
@interface TPArticleDetailCell()
@end
@implementation TPArticleDetailCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        [self setup];
    }
    return self;
}
-(void)setup{
    
    ViewRadius(self.image_view, 30.0);
    [self.image_view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(10.0f);
        make.left.mas_equalTo(10.0);
        make.size.mas_equalTo(CGSizeMake(60.0, 60.0));
    }];
    self.date_label.textAlignment = NSTextAlignmentRight;
    [self.date_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(28.0);
        make.right.mas_equalTo(-10.0);
        make.top.mas_equalTo(self.image_view.mas_top).offset(6.0);
        
    }];
    [self.title_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(28.0);
        make.left.mas_equalTo(self.image_view.mas_right).offset(10.0);
        make.top.mas_equalTo(self.date_label.mas_top);
        make.right.mas_equalTo(self.date_label.mas_left);
        
    }];
    
    self.detail_label.numberOfLines = 0;
    [self.detail_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.title_label.mas_left);
        make.right.mas_equalTo(-10.0);
        make.bottom.mas_equalTo(-10.0);
        make.top.mas_equalTo(self.title_label.mas_bottom).offset(5.0);
    }];
    
}

-(void)setModel:(TPArticleCommentModel *)model{
    _model = model;
    [self.image_view ym_setImageWithURL:model.user.head placeholderImage:Tripvi_avtor];
    self.title_label.text = model.user.alias;
    self.detail_label.text = model.reply_content;
    self.date_label.text = [NSDate timeWithTimeIntervalString:model.reply_time];
}
@end
